package vo;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * 买家（id、手机号、邮箱、用户名、密码、地址）
 */

@Entity
@Table(name="client")
public class Client {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;

	// 登录名 唯一标示
	//@Column(length = 11, nullable = false, unique = true)
	private String tel;

	// 邮箱 唯一标识
	//@Column(nullable = false, unique = true)
	private String email;

	// 用户名 昵称 可修改
	private String username;

	// 密码
	private String passwd;

	// 一个顾客对应多个地址
	@OneToMany(mappedBy = "customer", cascade = CascadeType.PERSIST)
	@Transient

	@ManyToOne(optional=false,fetch=FetchType.LAZY,targetEntity=Address.class)
	@JoinColumn(name="address_id" , nullable=false , updatable=false)
	private Set<Address> address = new HashSet<Address>();

	/*// 一个顾客对应多个订单
	@OneToMany(mappedBy = "cust", cascade = CascadeType.PERSIST)
	@Transient
	private Set<OrderForm> orderforms = new HashSet<OrderForm>();
*/
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPasswd() {
		return passwd;
	}

	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}

	public Set<Address> getAddress() {
		return address;
	}

	public void setAddress(Set<Address> address) {
		this.address = address;
	}
/*
	public Set<OrderForm> getOrderforms() {
		return orderforms;
	}

	public void setOrderforms(Set<OrderForm> orderforms) {
		this.orderforms = orderforms;
	}*/

}

